package com.hejia.alauda.service;

import java.util.List;

import com.hejia.alauda.entity.BaseEntity;
import com.hejia.alauda.entity.example.Example;
import com.hejia.alauda.persistence.BaseMapper;
import com.hejia.alauda.utils.Pager;


public abstract class BaseServiceImpl<T extends BaseEntity> implements BaseService<T> {
	
	protected abstract BaseMapper<T> getBaseMapper();
	
	public T selectByPrimaryKey(Long id){
		return getBaseMapper().selectByPrimaryKey(id);
	}
	
	public T selectOneByExample(Example<T> example){
		return getBaseMapper().selectOneByExample(example);
	}
	
	public List<T> selectByExample(Example<T> example, Pager<T> pager){
		return getBaseMapper().selectByExample(example, pager);
	}
	
	public int insert(T record){
		return getBaseMapper().insert(record);
	}
	
	public int insertWithNullValue(T record){
		return getBaseMapper().insertWithNullValue(record);
	}
	
	public int countByExample(Example<T> example){
		return getBaseMapper().countByExample(example);
	}
	
	public int countColByExample(String col,Example<T> example){
		return getBaseMapper().countColByExample(col, example);
	}
	
	public Double sumByExample(String field,Example<T> example){
		return getBaseMapper().sumByExample(field, example);
	}
	 
	public int deleteByExample(Example<T> example){
		return getBaseMapper().deleteByExample(example);
	}
	 
	public int deleteByPrimaryKey(T entity){
		return getBaseMapper().deleteByPrimaryKey(entity);
	}
	 
	public int updateByExample( T record,  Example<T> example){
		return getBaseMapper().updateByExample(record, example);
	}
	
	public int updateByExampleWithNullValue( T record, Example<T> example){
		return getBaseMapper().updateByExampleWithNullValue(record, example);
	}
	
	public int updateByPrimaryKey(T record){
		return getBaseMapper().updateByPrimaryKey(record);
	}
	
	public int updateByPrimaryKeyWithNullValue(T record){
		return getBaseMapper().updateByPrimaryKeyWithNullValue(record);
	}
	
	
}
